import java.util.*;
import java.lang.*;
import java.io.*;
public class ArraySort{
    String [] words;
    
    public ArraySort(String args) {
        
        String line = "";
        String inFile = "";
        int counter = 0;
        try{
        BufferedReader in = new BufferedReader(new FileReader(args));
        while ((line = in.readLine()) != null){
           StringTokenizer s = new StringTokenizer(line);
           while (s.hasMoreTokens()) {
               inFile += s.nextToken() + " ";
               counter++;
           }
        }
        System.out.println(inFile);
        words = new String[counter];
        StringTokenizer next = new StringTokenizer(inFile);
        for(int i = 0; i < words.length; i++){
            words[i] = next.nextToken();
        }
        
        }
        catch(IOException e){
        System.err.println(e);
        System.exit(0);
        }
        //String temp[] = new String [words.length];
        String min = "";
        for(int i = 0; i< words.length;i++){
            min = words[i];
            //System.out.println(min);
            int wordCount = 1;
            
            for(int j = i+1; j < words.length ; j++){
                if (min.compareToIgnoreCase(words[j]) > 0) {
                    String newWord = words[i];
                    words[i] = words[j];
                    min = words[j];
                    words[j] = newWord;
                    wordCount = 1;
                }
                if (min.compareToIgnoreCase(words[j]) == 0) {
                    wordCount ++;
                    for (int k = j; k < words.length; k++ ) {
                    }
                }
            }
           words[i] = min + " " + wordCount;
           System.out.println(words[i]);
        }
    
    }

    
    public static void main(String [] args){
        if (args.length != 1) {
        
        
            System.out.println("");
            System.out.println("usage: ArraySort <inputFile> <outputFile>\n");        
            
        }
        
        ArraySort a = new ArraySort(args[0]);

    }


}
